/*
 * =====================================================================================
 *
 *       Filename:  runLuaTest.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2012年02月09日 23时06分08秒 CST
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  lerosua (), lerosua@gmail.com
 *        Company:  Cyclone
 *
 * =====================================================================================
 */


#include <lua.h>
#include <lualib.h>
#include <stdio.h>

#define LUA_FILE  "test.lua"
#define err_exit(num,fmt,args...) \
	do{printf("[%s:%d] "fmt"\n",__FILE__,__LINE__,##args);exit(num);}while(0)

#define err_return(num,fmt,args...) \
	do{printf("[%s:%d] "fmt"\n",__FILE__,__LINE__,##args);return(num);}while(0)

void callLuaUploadPic(lua_State* L, char* picFile)
{
	lua_getglobal(L,"upload_pic");
	lua_pushstring(L,picFile);
	lua_pcall(L,1,LUA_MULTRET,0);

}

int main(int argc,char *argv[])
{
	lua_State* L= luaL_newstate();
	if(L == NULL)
		err_return(-1,"luaL_newsate() failed");
	int ret =0;
	ret = luaL_loadfile(L, LUA_FILE);
	if(ret !=0)
		err_return(-1,"luaL_loadfile() failed");
		
	//run script
	ret = lua_pcall(L,0,0,0);
	if(ret)
		err_return(-1,"lua_pcall() failed");
	lua_close(L);

	printf("\n");
	return 0;
}
